<template>
  <div class="container">
    <van-button
      type="default"
      round
      size="mini"
      @click="goBack"
      v-if="state.mapMes.level !== '0'"
    >
      <van-icon name="revoke" />
    </van-button>
    <div class="header">
      <p class="title">销售数据大屏</p>
      <p class="timeText">{{ state.date }}</p>
    </div>
    <van-row
      class="salesInfo"
      v-if="JSON.stringify(state.storeMessage) !== '{}'"
    >
      <van-col :span="12">
        <p>
          昨日销售额：<span>{{ state.shiShouTotalPrice }}</span>
        </p>
        <p>
          折扣金额：<span>{{ state.youHuiTotalPrice }}</span>
        </p>
      </van-col>
      <van-col :span="12">
        <p style="text-align: right">
          客单价：<span>{{ state.kdj }}</span>
        </p>
        <p style="text-align: right">
          退款金额：<span>{{ state.returnTotalPrice }}</span>
        </p>
      </van-col>
    </van-row>
    <van-row class="salesInfo" v-else>
      <van-col :span="10">
        <p style="text-align: center">
          {{ state.mapName }}
        </p>
        <p>
          昨日发货(万)：<span>{{ state.totalFh }}</span>
        </p>
      </van-col>
      <van-col :span="14">
        <p style="text-align: right">
          在册门店数：<span>{{ totalShops }}</span>
        </p>
        <p style="text-align: right">
          昨日销售(万)：<span>{{ state.totalXs }}</span>
        </p>
      </van-col>
    </van-row>
    <div class="mapBox">
      <el-amap :zoom="4" :zooms="[2, 30]" @init="init">
        <el-amap-geojson
          v-for="item in state.geos"
          :ref="getRef"
          :key="item.id"
          :visible="state.stores.length === 0"
          :geo="item.data"
          :bubble="false"
          :zIndex="999"
          :polygon-options="item.polygonOptions"
          :reEventWhenUpdate="true"
        />

        <el-amap-marker
          v-for="(marker, index) in state.mapTextMarkerList"
          :key="marker.name"
          :icon="marker.icon"
          :visible="state.stores.length === 0"
          :position="marker.position"
          :label="marker.label"
          :offset="marker.offset"
          :anchor="marker.anchor"
          @click="geojsonClick(marker)"
        />
        <!-- 显示门店信息 -->
        <!-- <el-amap-info-window
          v-model:visible="item.wShow"
          v-for="item in state.stores"
          :key="item.STORECODE"
          @close="
            () => {
              item.cShow = false;
            }
          "
          :anchor="'top-right'"
          :position="[item.DMJD, item.DMWD]"
        >
          <p>门店编码：{{ item.STORECODE }}</p>
          <p>门店名称：{{ item.STORENAME }}</p>
          <p>门店分类：{{ item.MDLB }}</p>
          <p>母子孙属性：{{ getMzsName(item.MDLB) }}</p>
          <p>门店地址：{{ item.MDXXDZ }}</p>
          <p>开业日期：{{ item.DYCFHSJ }}</p>
          <p>经营时间：{{ item.ZCYYSJ }}</p>
          <p>商圈属性：{{ item.YJSQ }}</p>
          <p>装修形象：{{ getZXXXname(item.ZXXX) }}</p>
          <p v-if="item.GDRQ">关店日期：{{ item.GDRQ }}</p>
          <p v-if="item.JYSC">经营时长：{{ item.JYSC }} 年</p>
        </el-amap-info-window> -->

        <!-- 点击门店显示半径敷设范围 -->
        <!-- <el-amap-circle
          v-for="item in state.stores"
          :key="item.STORECODE"
          :bubble="true"
          :center="[item.DMJD, item.DMWD]"
          :reEventWhenUpdate="true"
          :strokeWeight="3"
          :zIndex="1"
          :editable="item.cShow"
          :fillOpacity="0.1"
          :radius="1000"
          :visible="item.cShow"
        /> -->
        <!-- 卫星图层 -->
        <el-amap-layer-satellite
          :reEventWhenUpdate="true"
          :visible="state.satelliteShow"
        ></el-amap-layer-satellite>
        <!-- 显示门店点 -->
        <el-amap-mass-marks
          :visible="state.stores.length > 0"
          :data="state.stores"
          @click="storeMarkerClick"
          :styles="state.styles"
        />
      </el-amap>
    </div>
    <div class="chartBox" v-if="state.stores.length === 0">
      <div class="label">
        <img src="src/assets/imgs/icon.png" alt="" />
        <span>区域明细</span>
      </div>
      <div class="tableContent">
        <van-row class="thead">
          <van-col :span="6">
            <span>名称</span>
          </van-col>
          <van-col :span="6">
            <span>门店数</span>
          </van-col>
          <van-col :span="6">
            <span>发货金额(万)</span>
          </van-col>
          <van-col :span="6">
            <span>销售金额(万)</span>
          </van-col>
        </van-row>
        <van-row
          v-for="(item, index) in state.rsData"
          :key="index"
          :class="{ active: index % 2 !== 0, tbody: true }"
        >
          <van-col :span="6">
            <span>{{ item.name }}</span>
          </van-col>
          <van-col :span="6">
            <span>{{ item.totalShop }}</span>
          </van-col>
          <van-col :span="6">
            <span>{{ item.fhAll }}</span>
          </van-col>
          <van-col :span="6">
            <span>{{ item.xsAll }}</span>
          </van-col>
        </van-row>
      </div>
    </div>
    <div class="chartBox" v-if="JSON.stringify(state.storeMessage) !== '{}'">
      <div class="label">
        <img src="src/assets/imgs/icon.png" alt="" />
        <span>门店明细</span>
      </div>
      <div class="tableContent">
        <p class="active">
          <span>门店编码：</span>
          <span>{{ state.storeMessage.STORECODE }}</span>
        </p>
        <p>
          <span>门店名称：</span>
          <span>{{ state.storeMessage.STORENAME }}</span>
        </p>
        <p class="active">
          <span>门店分类：</span> <span>{{ state.storeMessage.MDLB }}</span>
        </p>
        <p>
          <span>母子孙属性：</span>
          <span>{{ getMzsName(state.storeMessage.MDLB) }}</span>
        </p>
        <p class="active">
          <span>装修形象：</span>
          <span>{{ getZXXXname(state.storeMessage.ZXXX) }}</span>
        </p>
        <p>
          <span>开业日期：</span> <span>{{ state.storeMessage.DYCFHSJ }}</span>
        </p>
        <p class="active">
          <span>经营时间：</span> <span>{{ state.storeMessage.ZCYYSJ }}</span>
        </p>
        <p>
          <span>商圈属性：</span> <span>{{ state.storeMessage.YJSQ }}</span>
        </p>

        <p class="active">
          <span>门店地址：</span> <span>{{ state.storeMessage.MDXXDZ }}</span>
        </p>
      </div>
    </div>
  </div>
</template>
<script setup>
import { showLoading, msgFn, hideLoading } from 'src/utils';
import * as turf from '@turf/turf';
import { ide, zoneStore, sellOrderInfos } from 'src/plugins/http/server';
import { ztApi, scApi } from 'src/plugins/http/api.js';
import env from 'src/config';
const state = reactive({
  mapName: '全国',
  qg: { level: '0', value: '000000', label: '' },
  gs: {},
  zq: {},
  zqSalesInfo: [],
  mapMes: { level: '0', value: '000000', label: '' },
  geos: [],
  rsData: [],
  stores: [],
  refs: [],
  //实收金额
  shiShouTotalPrice: 0,
  //优惠总金额
  youHuiTotalPrice: 0,
  //优惠订单数
  youHuiNum: 0,
  //销售订单数
  sellNum: 0,
  //退货订单数
  returnNum: 0,
  //客单价
  kdj: 0,
  //退货总金额
  returnTotalPrice: 0,
  storeMessage: {},
  ZXXXData: [
    {
      name: '第4代',
      value: '0',
    },
    {
      name: '第5代',
      value: '1',
    },
    {
      name: '第6代',
      value: '2',
    },
    {
      name: '第6.5代',
      value: '4',
    },
    {
      name: '无',
      value: '3',
    },
    {
      name: '全部',
      value: '99',
    },
  ], //装修信息对应表
  zqMarkerPolygon: [],
  styles: [
    {
      url: `${env.staticUrl}/uploads/static/dianzhongdian.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 0,
    },
    {
      url: `${env.staticUrl}/uploads/static/dianzhongdian.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 1,
    },
    {
      url: `${env.staticUrl}/uploads/static/biaozhundian.png`,
      anchor: [3, 3],
      size: [30, 15],
      zIndex: 2,
    },
    {
      url: `${env.staticUrl}/uploads/static/zhuangui.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 3,
    },
    {
      url: `${env.staticUrl}/uploads/static/level-1.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 4,
    },
    {
      url: `${env.staticUrl}/uploads/static/level-2.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 5,
    },
    {
      url: `${env.staticUrl}/uploads/static/level-3.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 6,
    },
    {
      url: `${env.staticUrl}/uploads/static/new.png`,
      anchor: [3, 3],
      size: [20, 20],
      zIndex: 7,
    },
    {
      url: `${env.staticUrl}/uploads/static/newStore.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 8,
    },
    {
      url: `${env.staticUrl}/uploads/static/reserveStore.png`,
      anchor: [3, 3],
      size: [30, 30],
      zIndex: 9,
    },
  ],
  date: '',
  time: null,
  totalFh: 0,
  totalXs: 0,
  mapTextMarkerList: [],
});
const totalShops = computed(() => {
  let count = 0;
  state.totalFh = 0;
  state.totalXs = 0;
  state.rsData.forEach((e) => {
    count = UtilTools.add(e.totalShop, count, 0);
    state.totalFh = UtilTools.add(e.fhAll, state.totalFh, 2);
    state.totalXs = UtilTools.add(e.xsAll, state.totalXs, 2);
  });
  return count;
});
const colors = [
  '#EF731B',
  '#00A1EA',
  '#EC7960',
  '#FCDABA',
  '#E09FC5',
  '#96CEB4',
  '#FC9C3D',
  '#D3E081',
  '#FBECBD',
  '#DDE543',
  '#C9E8FB',
  '#6DC7DD',
  '#F5C67F',
  '#5A6B81',
  '#F4ED52',
  '#EF731B',
  '#00A1EA',
  '#EC7960',
  '#FCDABA',
  '#E09FC5',
  '#96CEB4',
  '#FC9C3D',
  '#D3E081',
  '#FBECBD',
  '#DDE543',
  '#C9E8FB',
  '#6DC7DD',
  '#F5C67F',
  '#5A6B81',
  '#F4ED52',
];
getTime();
function getTime() {
  state.date = UtilTools.formatDateTime({ type: 'YYYY-MM-DD hh:mm:ss' });
}
let Map = null;
const init = (map) => {
  Map = map;
};
getData(state.qg);
state.time = setInterval(() => getTime(), 1000);

function getRef(e) {
  state.refs.push(e);
}

function mapFenceAreasV3(item, cb) {
  let params = {
    funumber: item.value,
  };
  ide({
    data: {
      url: scApi.mapFenceAreasV3.url,
      headers: {
        'API-TOKEN': scApi.mapFenceAreasV3.apiToken,
      },
      method: 'post',
      datas: {
        inFields: params,
        pageSize: 999,
        pageNo: 1,
      },
    },
    opts: { isLoading: '0' },
  }).then(({ data }) => {
    data.data.forEach((e, i) => {
      e.data = JSON.parse(e.data);
      e.polygonOptions = {
        strokeColor: colors[i],
        fillColor: colors[i],
        bubble: true,
      };
    });
    state.geos = data.data;
    state.mapTextMarkerList = getMarkers(state.geos);
    setTimeout(() => Map.setFitView(), 500);
    cb();
  });
}
function queryMapInfo(item, cb) {
  let params = {
    name: item.label,
    code: item.value,
  };
  if (item.level === '0') {
    params.level = 1;
  } else if (item.level === 'gs') {
    params.level = 2;
  }
  ide({
    data: {
      url: ztApi.queryMapInfo.url,
      method: 'post',
      datas: {
        level: params.level,
        name: params.name,
        code: params.code,
      },
    },
    opts: { isLoading: '0' },
  }).then(({ data }) => {
    data.data.forEach((e) => {
      e.geoData = JSON.parse(e.geoData);
      e.zyfh = UtilTools.div(e.zyfh, 10000, 2);
      e.jmfh = UtilTools.div(e.jmfh, 10000, 2);
      e.zybd = UtilTools.div(e.zybd, 10000, 2);
      e.jmbd = UtilTools.div(e.jmbd, 10000, 2);
      e.totalShop = UtilTools.add(e.zyshop, e.jmshop);
      e.fhAll = UtilTools.add(e.zyfh, e.jmfh);
    });
    data.data.sort((a, b) => parseInt(b.totalShop) - parseInt(a.totalShop));
    state.rsData = data.data;
    cb();
  });
}
function querySaleGroupByFgs() {
  ide({
    data: {
      url: scApi.querySaleGroupByFgs.url,
      method: 'post',
      headers: {
        'API-TOKEN': scApi.querySaleGroupByFgs.apiToken,
      },
      datas: {
        inFields: {
          SFDATE: UtilTools.formatDateTime({
            date: Date.now() - 1000 * 60 * 60 * 24,
            type: 'YYYY-MM-DD',
          }),
        },
      },
    },
    opts: { isLoading: '0' },
  }).then(({ data }) => {
    state.rsData.forEach((e) => {
      e.xsAll = UtilTools.div(
        data.data.find((y) => y.FGSNAME === e.name).SALEVALUE,
        10000,
        2
      );
    });
    hideLoading();
  });
}
function querySaleGroupByZq(item) {
  ide({
    data: {
      url: scApi.querySaleGroupByZq.url,
      method: 'post',
      headers: {
        'API-TOKEN': scApi.querySaleGroupByZq.apiToken,
      },
      datas: {
        inFields: {
          SFDATE: UtilTools.formatDateTime({
            date: Date.now() - 1000 * 60 * 60 * 24,
            type: 'YYYY-MM-DD',
          }),
          FGSNAME: item.label,
        },
      },
    },
    opts: { isLoading: '0' },
  }).then(({ data }) => {
    state.rsData.forEach((e) => {
      e.xsAll = UtilTools.div(
        data.data.find((y) => y.ZQ === e.name).SALEVALUE,
        10000,
        2
      );
    });
    state.zqSalesInfo = state.rsData;
    hideLoading();
  });
}

function getData(item) {
  if (['0', 'gs'].includes(item.level)) {
    showLoading({
      message: '数据加载中...',
    });

    mapFenceAreasV3(item, () => {
      queryMapInfo(item, () => {
        if (item.level === 'gs') {
          querySaleGroupByZq(item);
        } else if (item.level === '0') {
          querySaleGroupByFgs(item);
        }
      });
    });
  } else {
    state.rsData = state.zqSalesInfo.filter((e) => e.name === item.label);
    getZQstores(item);
  }
}
function geojsonClick(e) {
  state.mapName = e.name;
  let data = { level: e.level, value: e.code, label: e.name };
  state.mapMes = data;
  if (e.level === 'gs') {
    state.gs = data;
  } else if (e.level === 'zq') {
    state.zq = data;
    // console.log(1111);
    // console.log(e);
  }
  getData(data);
}
function getMarkers(markerList) {
  return markerList.map((e) => {
    return {
      icon: 'https://main.hsh.com.cn/report/images/zq.png',
      content: '',
      position: e.center.split(','),
      label: {
        offset: new AMap.Pixel(-50, 25), //修改label相对于marker的位置
        content: `<div style="color:#E95520;border:none;font-size:10px;font-weight:bold">${e.label}</div>`,
      },
      draggable: true,
      anchor: 'center', //设置锚点
      name: e.label,
      geoData: e.data,
      code: e.value,
      level: e.level,
    };
  });
}

function getTimeDuration(startTime, endTime) {
  if (!endTime) {
    endTime = UtilTools.formatDateTime({ type: 'YYYY-MM-DD' });
  }
  let tTime =
    new Date(endTime.replace(' ', 'T')) - new Date(startTime.replace(' ', 'T'));
  tTime = tTime / 1000 / 60;
  let tMin = Math.floor(tTime);
  let year = UtilTools.div(tMin, 525600, 1);
  return year;
}

//店铺数据整理
function arrangeData(data) {
  data.forEach((e) => {
    e.cShow = false;
    e.wShow = false;
    e.lnglat = [e.DMJD, e.DMWD];
    if (e.ERPMDZT === '关店' && e.DYCFHSJ && e.GDRQ) {
      e.JYSC = getTimeDuration(e.DYCFHSJ, e.GDRQ);
    } else if (e.ERPMDZT !== '关店' && e.DYCFHSJ) {
      e.JYSC = getTimeDuration(e.DYCFHSJ);
    } else {
      e.JYSC = 0;
    }
    if (e.MDLB === '标准店') {
      e.style = 0;
      e.icon = 'https://main.hsh.com.cn/report/images/member/dianzhongdian.png';
    } else if (e.MDLB === '旗舰店') {
      e.style = 2;
      e.icon = 'https://main.hsh.com.cn/report/images/member/biaozhundian.png';
    } else if (e.MDLB === '专柜') {
      e.style = 3;
      e.icon = 'https://main.hsh.com.cn/report/images/member/zhuangui.png';
    }
    if (e.DYCFHSJ && e.DYCFHSJ.indexOf(new Date().getFullYear()) > -1) {
      e.style = 7;
      e.icon = 'https://main.hsh.com.cn/report/images/member/new.png';
    }
  });
  return data;
}

//判断门店数据准确值  缺失折不显示
function checkStores(data) {
  let res = data.filter(
    (e) =>
      !!e.DMJD &&
      !!e.DMWD &&
      !isNaN(Number(e.DMWD)) &&
      !isNaN(Number(e.DMJD)) &&
      e.DMJD < 135 &&
      e.DMJD > 73 &&
      e.DMWD > 3 &&
      e.DMWD < 53 &&
      !['社区电商', '渠道'].includes(e.EJSQ) &&
      ['加盟', '直营', '连锁商超'].includes(e.STORETYPE) &&
      ['加盟', '直营', '直属商超'].includes(e.FCHLX) &&
      !['团购', '渠道', null].includes(e.MDLX) &&
      ['加盟', '直营', ''].includes(e.JYXZ)
  );
  return res;
}

//设置地图显示区域
function setMapView(type, arr, gap) {
  if (type === 'polygon') {
    let polygon = turf.polygon([arr]);
    let bbox = turf.bbox(polygon);
    bbox[0] = UtilTools.cut(bbox[0], gap);
    bbox[1] = UtilTools.cut(bbox[1], gap);
    bbox[2] = UtilTools.add(bbox[2], gap);
    bbox[3] = UtilTools.add(bbox[3], gap);
    Map.setBounds(bbox);
  }
}
//获取装修形象名字
function getZXXXname(value) {
  if (value) {
    return state.ZXXXData.find((e) => e.value === value)?.name;
  }
  return '';
}
//获取母子孙名字
function getMzsName(value) {
  let arr = [
    {
      name: '旗舰店',
      value: '母店',
    },
    {
      name: '标准店',
      value: '子店',
    },
    {
      name: '专柜',
      value: '孙店',
    },
  ];
  if (value) {
    return arr.filter((e) => e.name === value)[0].value;
  }
  return '';
}

function storeMarkerClick({ data }) {
  state.stores.forEach((o) => {
    o.cShow = false;
    o.wShow = false;
  });
  data.cShow = true;
  data.wShow = true;
  state.storeMessage = data;
  let startTime = UtilTools.formatDateTime({
    date: Date.now() - 1000 * 60 * 60 * 24,
    type: 'YYYY-MM-DD',
  });
  let endTime = UtilTools.formatDateTime({
    type: 'YYYY-MM-DD',
  });
  sellOrderInfos({
    data: {
      shopId: state.storeMessage.STORECODE,
      startTime,
      endTime,
      pageNo: 1,
      appkey:
        '4D48433768345243625A4145316F6B2F396D50534243655A7444592B41774C7636566552645231627464616D714B566A4E51364C464C50646D47674A564B6755',
      pageSize: 9999,
    },
  })
    .then(({ data }) => {
      if (data.Total) {
        setData(data.sellOrderInfos);
      } else {
        // that.resetData();
        // that.$utils.hideLoading();
        // that.$utils.showToast({
        //   title: '未能查到小票数据',
        // });
      }
    })
    .catch((e) => {
      console.log(e);
      //   that.$utils.showModal({
      //     title: e,
      //   });
    });

  setTimeout(() => Map.setZoomAndCenter(17, [data.DMJD, data.DMWD]), 500);
}

function setData(data) {
  const map = {};
  const returnMap = {};
  //实收金额
  state.shiShouTotalPrice = 0;
  //优惠总金额
  state.youHuiTotalPrice = 0;
  //优惠订单数
  state.youHuiNum = 0;
  //销售订单数
  state.sellNum = 0;
  //退货订单数
  state.returnNum = 0;
  //客单价
  state.kdj = 0;
  //退货总金额
  state.returnTotalPrice = 0;
  data.forEach((e, index) => {
    const saleType = ['1', '5', 'A', 'E', 'a', 'e', 'T1', 'T5', 'G'];
    const returnSaleType = ['2', '4', 'B', 'D', 'b', 'f', 'T2', 'T6', 'H'];
    if (saleType.includes(e.sellhead.saletype)) {
      state.shiShouTotalPrice = UtilTools.add(
        state.shiShouTotalPrice,
        e.sellhead.factpayvalue
      );
      state.sellNum++;
      if (e.sellhead.totaldiscvalue) {
        state.youHuiTotalPrice = UtilTools.add(
          state.youHuiTotalPrice,
          e.sellhead.totaldiscvalue
        );
        state.youHuiNum++;
      }
      const { payments } = e;
      payments.forEach((payment, i) => {
        const { payname, money, flag } = payment;
        if (map[payname]) {
          map[payname].money = UtilTools.add(map[payname].money, money);
          map[payname].total += 1;
        } else {
          map[payname] = { money, total: 1 };
        }
      });
    }
    if (returnSaleType.includes(e.sellhead.saletype)) {
      const { payments } = e;
      payments.forEach((payment, i) => {
        const { payname, money, flag } = payment;
        if (returnMap[payname]) {
          returnMap[payname].money = UtilTools.add(
            returnMap[payname].money,
            money
          );
        } else {
          returnMap[payname] = { money };
        }
      });
      state.returnTotalPrice = UtilTools.add(
        state.returnTotalPrice,
        e.sellhead.factpayvalue
      );
      state.returnNum++;
    }
  });
  //获取现金找零值
  let findCash = 0;
  Object.keys(map).forEach((k) => {
    if (k == '现金找零') {
      findCash = UtilTools.add(map[k].money, 0, 2);
    }
  });

  //优惠总金额
  state.youHuiTotalPrice = UtilTools.add(state.youHuiTotalPrice, 0, 2);
  //优惠订单数
  state.youHuiNum = UtilTools.add(state.youHuiNum, 0, 2);
  //销售订单数
  state.sellNum = UtilTools.add(state.sellNum, 0, 2);
  //退货订单数
  state.returnNum = UtilTools.add(state.returnNum, 0, 2);
  //退货总金额
  state.returnTotalPrice = UtilTools.add(state.returnTotalPrice, 0, 2);
  //实收金额
  state.shiShouTotalPrice = UtilTools.continuityCut(
    [state.shiShouTotalPrice, findCash, state.returnTotalPrice],
    2
  );
  state.kdj = UtilTools.div(
    state.shiShouTotalPrice,
    UtilTools.add(state.returnNum, state.sellNum, 2),
    2
  );
}

function goBack() {
  state.storeMessage = {};
  state.stores = [];
  if (state.mapMes.level === 'gs') {
    state.mapName = '全国';
    state.mapMes = state.qg;
    getData(state.qg);
  } else if (state.mapMes.level === 'zq') {
    state.mapName = state.gs.label;
    state.mapMes = state.gs;
    getData(state.gs);
  }
}

function getZQstores(item) {
  let params = {
    ZQ: item.label,
    attr: [
      'DMJD',
      'DMWD',
      'STORECODE',
      'STORENAME',
      'JYXZ',
      'SQX',
      'SHEN',
      'SHI',
      'FGSNAME',
      'MDZT',
      'OAMDZT',
      'ERPMDZT',
      'ZQ',
      'GDRQ',
      'EJSQ',
      'YJSQ',
      'STORETYPE',
      'FCHLX',
      'MDLX',
      'MDXXDZ',
      'MDLB',
      'iMdsx',
      'id',
      'MDZJ',
      'DYCFHSJ',
      'ZXXX',
      'MDMJ',
      'KYRQ',
      'ZCYYSJ',
      'MDZXXINGZH',
      'ZHYCFHSJ',
    ],
    ERPMDZT: ['正常营业'],
  };
  zoneStore({
    data: params,
    opts: { isLoading: '0' },
  }).then(({ data }) => {
    if (data && data.length) {
      let storesData = arrangeData(data);
      state.stores = checkStores(storesData);
      state.zqMarkerPolygon = [];
      state.stores.forEach((e, i) => {
        state.zqMarkerPolygon.push([e.DMJD, e.DMWD]);
        if (i === state.stores.length - 1) {
          state.zqMarkerPolygon.push([
            state.stores[0].DMJD,
            state.stores[0].DMWD,
          ]);
        }
      });
      setMapView('polygon', state.zqMarkerPolygon, 0.3);
    }
  });
}
</script>

<style scoped lang="less">
@import 'index';
</style>
